package com.quanshu.exchange.ui.gui.profile.member;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.quanshu.exchange.R;
import com.quanshu.exchange.support.entity.MemberOrderEntity;
import com.quanshu.exchange.support.utils.RxViewHelper;
import com.quanshu.exchange.ui.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OrderInfoDetailActivity extends BaseActivity {

    @BindView(R.id.back)
    LinearLayout back;
    @BindView(R.id.tv_balance)
    TextView tvBalance;
    @BindView(R.id.tv_order_time)
    TextView tvOrderTime;
    @BindView(R.id.tv_account)
    TextView tvAccount;
    @BindView(R.id.tv_rate)
    TextView tvRate;
    @BindView(R.id.tv_bonus)
    TextView tvBonus;
    @BindView(R.id.tv_status)
    TextView tvStatus;
    @BindView(R.id.tv_pay_account)
    TextView tvPayAccount;
    @BindView(R.id.tv_pay_way)
    TextView tvPayWay;

    private MemberOrderEntity memberOrderEntity;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_member_order_detail);
        ButterKnife.bind(this);
        initIntent();
        initView();
        initListener();
    }

    private void initIntent() {
        memberOrderEntity = (MemberOrderEntity) getIntent().getSerializableExtra("MemberOrderEntity");
    }

    private void initView() {
        if (memberOrderEntity != null) {
            tvOrderTime.setText(memberOrderEntity.getCreate_time());
            tvBalance.setText(memberOrderEntity.getSum_price() + "");
            tvAccount.setText(memberOrderEntity.getOrder_no());
            tvRate.setText(memberOrderEntity.getChance());
            tvBonus.setText(memberOrderEntity.getSum_price() + "");
            if (memberOrderEntity.getDistribution_status().equals("已收益")) {
                tvStatus.setBackgroundResource(R.drawable.shape_corner_90_solid_red);
            } else {
                tvStatus.setBackgroundResource(R.drawable.shape_corner_90_solid_yellow);
            }
            tvStatus.setText(memberOrderEntity.getDistribution_status());
            tvPayAccount.setText(memberOrderEntity.getUsername());
            tvPayWay.setText(memberOrderEntity.getPayment_options());
        }
    }

    private void initListener() {
        RxViewHelper.getInstance().clicks(back, aVoid -> finish());

    }
}
